package com.lwx.es;

import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.MatchAllQueryBuilder;
import org.elasticsearch.index.query.MultiMatchQueryBuilder;
import org.elasticsearch.index.query.MultiMatchQueryBuilder.Type;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.index.query.QueryStringQueryBuilder;
import org.elasticsearch.index.query.TermQueryBuilder;
import org.junit.Test;

public class EsTest {
	
	@Test
	public void testMultiMatchQueryBuilder(){
		MultiMatchQueryBuilder query = new MultiMatchQueryBuilder("testString",
				"f1*", "f2").analyzer("ik").type(Type.PHRASE);
		System.out.println(query.toString());
	}

	@Test
	public void testBoolQueryBuilder() {
		MultiMatchQueryBuilder query = new MultiMatchQueryBuilder("testString",
				"f1*", "f2").analyzer("ik").type(Type.PHRASE);
		BoolQueryBuilder bqb = new BoolQueryBuilder().must(query);
		System.out.println(bqb.toString());
	}
	
	@Test
	public void testTermQueryBuilder(){
		TermQueryBuilder termQueryBuilder = QueryBuilders.termQuery("f1", "v1");
		System.out.println(termQueryBuilder.toString());
	}
	
	@Test
	public void testQueryStringQueryBuilder(){
		QueryStringQueryBuilder queryStringQueryBuilder = QueryBuilders.queryString("abc");
		System.out.println(queryStringQueryBuilder.toString());
	}
	
	@Test
	public void testMatchAllQueryBuilder(){
		MatchAllQueryBuilder matchAllQueryBuilder = QueryBuilders.matchAllQuery();
		matchAllQueryBuilder.boost(2);
		System.out.println(matchAllQueryBuilder.toString());
	}
	
	@Test
	public void testMatchAllQueryBuildesr(){
		//MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchPhraseQuery(name, text);
		//System.out.println(MatchQueryBuilder.toString());
	}
}
